package com.yanhui.modal.ai;


import com.yanhui.utils.ApiAccount;
import com.yanhui.utils.string._stringUtils;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;



public class SignEntity {

    private int app_id = ApiAccount.TENCENT_APP_ID_AI;
    private String app_key = ApiAccount.TENCENT_APP_KEY_AI;
    private int time_stamp = (int) (System.currentTimeMillis() / 1000);
    private String nonce_str = _stringUtils.getCharAndNumr(17, 3);
    private String sign;
    private String text;
    public String getText() {
        return text;
    }
    public void setText(String text) {
        this.text = text;
    }
    public int getApp_id() {
        return app_id;
    }
    public void setApp_id(int app_id) {
        this.app_id = app_id;
    }
    public String getApp_key() {
        return app_key;
    }
    public void setApp_key(String app_key) {
        this.app_key = app_key;
    }
    public int getTime_stamp() {
        return time_stamp;
    }
    public void setTime_stamp(int time_stamp) {
        this.time_stamp = time_stamp;
    }
    public String getNonce_str() {
        return nonce_str;
    }
    public void setNonce_str(String nonce_str) {
        this.nonce_str = nonce_str;
    }
    public String getSign() {
        return sign;
    }
    public void setSign(String sign) {
        this.sign = sign;
    }
    public SignEntity() {
    }

    public SignEntity(String text,int type) {
        Map<String, String> person_Id_body = new HashMap<String, String>();

        person_Id_body.put("app_id", app_id+"");
        person_Id_body.put("time_stamp", time_stamp+"");
        person_Id_body.put("nonce_str", nonce_str);
        person_Id_body.put("text", text);

        try {
            String sign = "";
            if(type == 1){
                //POST
                sign = TencentAISignSort.getSignature(person_Id_body);
            }else{
                sign = TencentAISignSort.getSignatureforNLP(person_Id_body);
            }
//			String sign = TencentAISignSort.getSignatureforNLP(person_Id_body);
            this.sign = sign.toUpperCase();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public SignEntity(int app_id, String app_key, int time_stamp, String nonce_str, String sign,String text) {
        super();
        this.app_id = app_id;
        this.app_key = app_key;
        this.time_stamp = time_stamp;
        this.nonce_str = nonce_str;
        this.sign = sign;
        this.text = text;
    }
    @Override
    public String toString() {
        return "SignEntity [app_id=" + app_id + ", app_key=" + app_key + ", time_stamp=" + time_stamp + ", nonce_str="
                + nonce_str + ", sign=" + sign + "]";
    }


}
